﻿function TLabel(point) {
    this.point = point;
    this.content = '';
}

TLabel.prototype = new GOverlay();

TLabel.prototype.initialize = function(map) {
    var div = document.createElement("div");
    div.style.position = "absolute";
    map.getPane(G_MAP_MAP_PANE).appendChild(div);
    this.map = map;
    this.div = div;
    this.div.innerHTML = this.content;
};

// Remove the main DIV from the map pane
TLabel.prototype.remove = function() {
    this.div.parentNode.removeChild(this.div);
};

// Copy our data to a new ExRectangle
TLabel.prototype.copy = function() {
    return new TLabel(this.point);
};

TLabel.prototype.setLatLng = function(pt) {
    this.point = pt;
    this.redraw(true);
};

TLabel.prototype.getLatLng = function() {
    return this.point;
};
// Redraw the ExRectangle based on the current projection and zoom level
TLabel.prototype.setContent = function(content) {
    this.content = content;
    
};

TLabel.prototype.redraw = function(force) {
    var b = this.map.fromLatLngToDivPixel(this.point);
    var x = parseInt(b.x);
    var y = parseInt(b.y);
//    with (Math) {
//        switch (this.anchorPoint) {
//            case 'topLeft': break;
//            case 'topCenter': x -= floor(this.w / 2); break;
//            case 'topRight': x -= this.w; break;
//            case 'midRight': x -= this.w; y -= floor(this.h / 2); break;
//            case 'bottomRight': x -= this.w; y -= this.h; break;
//            case 'bottomCenter': x -= floor(this.w / 2); y -= this.h; break;
//            case 'bottomLeft': y -= this.h; break;
//            case 'midLeft': y -= floor(this.h / 2); break;
//            case 'center': x -= floor(this.w / 2); y -= floor(this.h / 2); break;
//            default: break;
//        }
    //    }

    y -= Math.floor(this.div.offsetHeight / 2); 
    //var d = document.getElementById(this.id);
    this.div.style.left = x + 'px';
    this.div.style.top = y  + 'px';
    this.div.innerHTML = this.content;
};